// api.js
const request = require('./request.js'); // 引入封装的 request 模块

// 定义 API 方法
const API = {
  //微信自带的方法

  //获取用户模糊位置
  getFuzzyLocation : () =>
    new Promise((resolve, reject) =>
    wx.getFuzzyLocation({ type: 'wgs84', success: resolve, fail: reject })
  ),
  //获取用户精准位置
  getUserLocation : () =>
    new Promise((resolve, reject) =>
    wx.getLocation({ type: 'gcj02', success: resolve, fail: reject })
  ),

  //调用你三方接口
  thirdRequest : (options) =>
    new Promise((resolve, reject) =>
    wx.request({ ...options, success: resolve, fail: reject })
  ),
  //用户登录接口
  userLogin:(data)=>request.post('/login',data),
  //获取当前登录用户信息接口
  userInfo:()=>request.get('/getUserInfo'),
  //加载首页附近场地数据
  nearByLocationData:(data)=>request.get('/wechat/nearby/locationData',data),
  //根据ID获取场地详情
  nearByPlaceById:(id)=>request.get("/wechat/nearby/details/"+id),
  //查询场地列表
  nearByPlaceList:(data)=>request.get("/wechat/nearby/list/",data),
  //场地预约
  bookingPlace:(data)=>request.post("/wechat/nearby/booking/",data),
  //教学视频分页查询
  teachingVideoList:(data)=>request.get('/system/teaching/getList',data),

  //商品列表查询
  productList:(data)=>request.get('/system/product/list',data),

  //赛事视频
  tournamentList:(data)=>request.get('/system/tournament/list',data),

  //获取教练列表
  coachList:(data)=>request.get('/system/coach/getList',data),
  //获取教练详情
  coachDetail:(id)=>request.post('/system/coach/details/'+id),
  //教练预约
  coachBooking:(data)=>request.post('/system/coachBooking/addOrUpdate',data),

  //获取测评视频
  evaluateVideoList:(data)=>request.get('/system/testVideo/list',data),

  //获取我的场地预约列表
  getMyCourtBookings:(data)=>request.get('/system/place/bookingRecords',data),
  //取消预约
  cancelCourtBooking:(id)=>request.post('/system/place/cancelBooking/'+id),
  
  //根据购物车获取商品信息
  getProductInfoByCart:(data)=>request.post('/system/product/shopCart',data),

  //结算
  shopCartOrder:(data)=>request.post('/system/order/order',data),
  
  //获取订单列表
  getOrderList:(data)=>request.get('/system/order/list',data),

  //获取文章列表
  getArticleList:(data)=>request.get('/system/article/list',data),
  //获取文章列表我的
  getArticleListMy:(data)=>request.get('/system/article/listMy',data),
  //获取文档详情
  getArticleDetail:(id)=>request.get('/system/article/details/'+id),

  //获取文章评论
  getArticleComments:(data)=>request.get('/system/comment/list',data),
  //添加评论
  addComment:(data)=>request.post('/system/comment/add',data),
  //删除评论
  deleteComment:(id)=>request.post('/system/comment/delete/'+id),

  //是否点赞收藏
  articleIsCollection:(id)=>request.get('/system/comment/isCollection/'+id),

  //点赞收藏操作
  articleCollectionOperate:(data)=>request.post('/system/comment/addCollection',data),
  //获取教练预约列表
  getCoachBookingRecords:(data)=>request.get('/system/coachBooking/bookingRecords',data),

    //取消预约
    cancelCoachBooking:(id)=>request.post('/system/coachBooking/cancelBooking/'+id),

    //我的收藏文章
    articleCollectio:(data)=>request.get('/system/article/collectList',data),

    //取消顶大
    cancelOrder:(id)=>request.post('/system/order/cancelOrder/'+id),

    //场地详情
    courtDetails:(id)=>request.get('/system/place/courtDetails/'+id),

    //获取已经预约的记录
    bookedRecords:(data)=>request.get('/system/place/bookedRecord',data),
    //更新当前用户信息
    updateUserInfo:(data)=>request.post('/updateUserInfo',data),
    
    //添加文章
    addArticle:(data)=>request.post('/system/article/addOrUpdate',data),
    
    //删除文章
    deleteArticle:(id)=>request.get('/system/article/delete/'+id)
};

module.exports = API;
